#include <iostream>
#include <set>
using namespace std;

set<int> G[205];

int main() {
    int n, x;
    unsigned k;
    cin >> n >> k;
    for (int i = 1; i <= n; ++i) {
        while (1) {
            cin >> x;
            if (x == 0) break;
            G[i].insert(x);
            G[x].insert(i);
        }
    }

    int ans = 0;
    for (int i = 1; i <= n; ++i) {
        if (G[i].size() >= k) ++ans;
    }

    cout << ans << endl;
    return 0;
}